﻿@page
@model IndexModel
@{
    ViewData["Title"] = "Roles";
}

@section Styles {
    <partial name="_JqGridStylesPartial" />
}

<h4>@ViewData["Title"]</h4>
<partial name="_StatusMessage" model="Model.StatusMessage" />
<div class="row">
    <div class="col-md-12">
        <table id="jqGrid"></table>
        <div id="jqGridPager"></div>
    </div>
</div>

@section Scripts {
    <partial name="_ValidationScriptsPartial" />
    <partial name="_JqGridScriptsPartial" />

    <script>
        var grid = $("#jqGrid");

        $(document).ready(function () {

            $.jgrid.defaults.responsive = true;
            $.jgrid.defaults.styleUI = 'Bootstrap';
            $.jgrid.defaults.whdth = 847;

            grid.jqGrid({
                url: '/Identity/Manage/Roles?handler=RoleList',
                datatype: 'json',
                mtype: "GET",

                jsonReader: {
                    root: "rows",
                    page: "page",
                    total: "total",
                    records: "records",
                    repeatitems: false
                    //cell: "cell",
                    //id: "id",
                    //userdata: "userdata",
                    //subgrid: {
                    //    root:"rows",
                    //    repeatitems: true,
                    //    cell:"cell"
                    //}
                },

                treeGrid: true, //启用树型Grid功能
                treeGridModel: 'adjacency', //表示返回数据的读取类型，分为两种：和adjacency
                ExpandColumn: 'name', //树型结构在哪列显示，在列模型中要放在非隐藏列的第一列
                treedatatype: "json",
                treeReader: {
                    parent_id_field: "parentId",
                    level_field: "depth",
                    leaf_field: "isLeaf",
                    expanded_field: "expanded",
                    loaded: 'loaded'//指示子节点是否已经加载，bool型，如果为fales，展开节点时会自动向服务器请求子节点
                },
                tree_root_level: 0,
                loadonce: true,

                colNames: ["Id", "角色名", "已启用", "创建人", "创建时间", "上次修改人", "上次修改时间"],
                colModel: [
                    { name: 'id', index: 'id', hidden: true, key: true },
                    { name: 'name', index: 'name' },
                    { name: 'isEnable', index: 'isEnable', align: "center", formatter: 'checkbox' },
                    { name: 'creationUserId', index: 'creationUserId', align: "center" },
                    { name: 'creationTime', index: 'creationTime', align: "center" },
                    { name: 'lastModificationUserId', index: 'lastModificationUserId', align: "center" },
                    { name: 'lastModificationTime', index: 'lastModificationTime', align: "center" }
                ],
                height: 200,
                altRows: true,
                width: 847,
                sortname: 'name',
                multiselect: true,
                sortable: true,
                caption: "角色列表"
            });
        });
    </script>
}
